<!doctype html>
<html lang="en">
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>Template • TodoMVC</title>
		<link rel="stylesheet" href="node_modules/todomvc-common/base.css">
		<link rel="stylesheet" href="node_modules/todomvc-app-css/index.css">
		<!-- CSS overrides - remove if you don't need it -->
		<link rel="stylesheet" href="css/app.css">
	</head>
	<body>
		<section class="todoapp" id="app">
			<header class="header">
				<h1>todos</h1>
				<input class="new-todo" placeholder="What needs to be done?" v-focus @keyup.enter="addItem" autofocus>
			</header>
			<!-- This section should be hidden by default and shown when there are todos -->
<!--				当没有事件的时候，也就是事件对象的长度为0，下拉框的样式为display=“none”-->
<!--				v-show:如果条件为false，运行后，还是生成了条件为false所在的标签，但是只是让其display属性为none，即该标签不进行显示，-->
			<section class="main" v-show="items.length">
       <!--input 的checkbox类型是一个boole类型，只有选中与没选中-->
<!--					复选框，需要双向绑定toggleAll-->
<!--					input的checkbox类型，只会返回true or false，默认第一次为false，点击为true，再点击为false-->
				<input id="toggle-all" class="toggle-all" type="checkbox" v-model="toggleAll">
				<label for="toggle-all"></label>
				<ul class="todo-list">
					<!-- These are here just to show the structure of the list items -->
					<!-- List items should get the class `editing` when editing and `completed` when marked as completed -->
          <!--绑定三种样式：未完成、已经完成、正在编辑，通过v-for来遍历filterItems里面对象-->
<!--						key属性的优点：保证同一个父元素的所有子元素有不同的key属性，有了key元素后，vue会记住每个子元素的所有顺序，提高渲染效率-->
					<li :class="{completed: item.completed,editing:currentItem===item}" v-for="(item,index) in filterItems" :key="item.id">
						<div class="view">
<!--								左边完成按钮部分-->
							<input class="toggle" type="checkbox" v-model="item.completed">
<!--								双击触发dobleclick事件，执行toEdit函数，让当前对象item的传给currentItem，通过绑定属性class，让改li切换编辑属性-->
							<label @dblclick="toEdit(item)">{{item.content}}</label>
							<button class="destroy" @click="deleteItem(item.id)"></button>
						</div>
            <!--编辑时候的输入框-->
<!--			      @keyup.enter="$event.target.blur"，触发回车事件之后又触发失去焦点blur事件，blur事件触发finshEdit函数保存数据-->
						<input class="edit" :value="item.content" @keyup.esc="cancelEdit" @keyup.enter="$event.target.blur" @blur="finishEdit(item,index,$event)" v-focus="item ===currentItem">
					</li>
<!--					<li>-->
<!--						<div class="view">-->
<!--							<input class="toggle" type="checkbox">-->
<!--							<label>Buy a unicorn</label>-->
<!--							<button class="destroy"></button>-->
<!--						</div>-->
<!--						<input class="edit" value="Rule the web">-->
<!--					</li>-->
				</ul>
			</section>
			<!-- This footer should be hidden by default and shown when there are todos -->
			<footer class="footer" v-show="items.length">
				<!-- This should be `0 items left` by default -->
				<span class="todo-count"><strong>{{ total }}</strong>item{{total ===1?'':'s'}} left</span>
				<!-- Remove this if you don't implement routing -->
<!--					通过切换filterStatus不同的值，filterItems函数会过滤在todo-list这个ul中渲染不同的状态的items-->
				<ul class="filters">
					<li>
						<a :class="{selected:filterStatus == '/'}" href="#/">All</a>
					</li>
					<li>
						<a :class="{selected:filterStatus == '/active'}" href="#/active">Active</a>
					</li>
					<li>
						<a :class="{selected:filterStatus == '/completed'}" href="#/completed">Completed</a>
					</li>
				</ul>
				<!-- Hidden if no completed items are left ↓ -->
				<button class="clear-completed" @click="clearCompleted" v-show="items.length>total">Clear completed</button>
			</footer>
		</section>
		<footer class="info">
<!--			<p>Double-click to edit a todo</p>-->
<!--			&lt;!&ndash; Remove the below line ↓ &ndash;&gt;-->
<!--			<p>Template by <a href="http://sindresorhus.com">Sindre Sorhus</a></p>-->
<!--			&lt;!&ndash; Change this out with your name and url ↓ &ndash;&gt;-->
<!--			<p>Created by <a href="http://todomvc.com">you</a></p>-->
<!--			<p>Part of <a href="http://todomvc.com">TodoMVC</a></p>-->
		</footer>
		<!-- Scripts here. Don't remove ↓ -->

		<script src="node_modules/todomvc-common/base.js"></script>
		<script src="./node_modules/vue/dist/vue.js"></script>
		<script src="js/app.js"></script>
	</body>
</html>
